import pandas as pd

input = {"input": {"triplet": [
    ["8vm7p8zl2rkfd402u9oesc7e", "userPosition", "非常规油气团队"],
    ["8vm7p8zl2rkfd402u9oesc7e", "userPost", "地质工程一体化研究"],
    ["地质工程一体化研究", "tag", "智能勘探"],
    ["非常规油气团队", "tag", "综合评价"],
    ["层位建模", "tag", "智能勘探"],
    ["措施挖潜", "tag", "综合评价"],
    ["措施挖潜", "tag", "智能研究"],
    ["措施挖潜", "tag", "基础研究"],
    ["措施挖潜", "productClassification", "微件"]
], "usage": [
    ["8vm7p8zl2rkfd402u9oesc7e", "层位建模", "6", "8"],
    ["8vm7p8zl2rkfd402u9oesc7e", "措施挖潜", "3", "2"]]}}

df = pd.DataFrame(input["input"]["triplet"], columns=["h", "r", "t"])
replace_dict = {r:r+"_v" for r in df["r"].unique()}
df_triplet_v = df.replace(replace_dict)
df_triplet_v = df_triplet_v.rename(columns={"h": "h_v", "t": "t_v"})
df_triplet_v = df_triplet_v.rename(columns={"h_v": "t", "t_v": "h"})
df = pd.concat([df,df_triplet_v])
print()